package service.custom.impl;

import java.util.List;

import dao.CompanybankcreditDao;
import dao.CompanybasicDao;
import dao.CompanycontactDao;
import dao.CompanymanageDao;
import dao.CompanypledgerDao;
import dao.PersonalbasicDao;
import dao.company.*;
import model.company.*;

import service.custom.CustomServiceDo;
import util.Sessions;

public class CustomServiceDoImpl implements CustomServiceDo {
	private CompanypledgerDao companypledgerDao;
	private CompanyforeigninvestmentDao companyforeigninvestmentDao;
	private CompanygivingcreditDao companygivingcreditDao;
	private CompanyguarantorDao companyguarantorDao;
	private CompanyinvestorDao companyinvestorDao;
	private CompanylistingDao companylistingDao;
	private CompanytopmanagerDao companytopmanagerDao;
	private CompanyprosecutedDao companyprosecutedDao;
	private CompanycontactDao companycontactDao;
	private CompanymanageDao companymanageDao;
	private CompanyexternalguaranteeDao companyexternalguaranteeDao;
	private CompanybankcreditDao companybankcreditDao;
	private PersonalbasicDao personalbasicDao;
	private CompanybasicDao companybasicDao;
	private CompanyassetsdebtDao assetsdebtDao;
	private CompanycashflowDao companycashflowDao;
	private CompanyprofitDao companyprofitDao;
	private CompanyotherloanDao companyotherloanDao;
	private CompanyfileDao companyfileDao;
	



	public CompanyfileDao getCompanyfileDao() {
		return companyfileDao;
	}


	public void setCompanyfileDao(CompanyfileDao companyfileDao) {
		this.companyfileDao = companyfileDao;
	}


	public CompanyotherloanDao getCompanyotherloanDao() {
		return companyotherloanDao;
	}


	public void setCompanyotherloanDao(CompanyotherloanDao companyotherloanDao) {
		this.companyotherloanDao = companyotherloanDao;
	}


	public CompanyprofitDao getCompanyprofitDao() {
		return companyprofitDao;
	}


	public void setCompanyprofitDao(CompanyprofitDao companyprofitDao) {
		this.companyprofitDao = companyprofitDao;
	}


	public CompanycashflowDao getCompanycashflowDao() {
		return companycashflowDao;
	}


	public void setCompanycashflowDao(CompanycashflowDao companycashflowDao) {
		this.companycashflowDao = companycashflowDao;
	}


	public CompanyassetsdebtDao getAssetsdebtDao() {
		return assetsdebtDao;
	}


	public void setAssetsdebtDao(
			CompanyassetsdebtDao assetsdebtDao) {
		this.assetsdebtDao = assetsdebtDao;
	}


	public CompanybankcreditDao getCompanybankcreditDao() {
		return companybankcreditDao;
	}


	public void setCompanybankcreditDao(CompanybankcreditDao companybankcreditDao) {
		this.companybankcreditDao = companybankcreditDao;
	}


	public CompanymanageDao getCompanymanageDao() {
		return companymanageDao;
	}


	public void setCompanymanageDao(CompanymanageDao companymanageDao) {
		this.companymanageDao = companymanageDao;
	}


	
	
	@Override
	public void manageSave(Companymanage cmanage) {
		companymanageDao.save(cmanage);
	}
	
	
	@Override
	public void pledgerSave(Companypledger companypledger) {
		companypledgerDao.save(companypledger);		
	}

	@Override
	public void foreigninvestorSave(Companyforeigninvestment cforeigninvestor) {
		companyforeigninvestmentDao.save(cforeigninvestor);		
	}

	@Override
	public void contactSave(Companycontact ccontact) {
		companycontactDao.save(ccontact);		
	}
	
	@Override
	public void topmanagerSave(Companytopmanager ctopmanager) {
		companytopmanagerDao.save(ctopmanager);
	}

	@Override
	public void givingcreditSave(Companygivingcredit cgivingcredit) {
		companygivingcreditDao.save(cgivingcredit);
	}

	@Override
	public void guarantorSave(Companyguarantor cguarantor) {
		companyguarantorDao.save(cguarantor);
	}

	@Override
	public void investorSave(Companyinvestor cinvestor) {
		companyinvestorDao.save(cinvestor);
	}

	@Override
	public void listingSave(Companylisting clisting) {
		companylistingDao.save(clisting);
	}

	@Override
	public void prosecutedSave(Companyprosecuted cprosecuted) {
		companyprosecutedDao.save(cprosecuted);
	}
	
	@Override
	public String companySave(Companybasic cbasic) {
		if(companybasicDao.findOne("id", cbasic.getId())==null){
			Companybasic c=companybasicDao.save(cbasic);
			Sessions.set("companyid",c.getId());
			return "TRUE";
		}else{
			return "组织机构代码已存在";
		}
	}	

	@Override
	public String companyUpdate(Companybasic cbasic) {
		Companybasic c=companybasicDao.save(cbasic);
		Sessions.set("companyid",c.getId());
		return "TRUE";
	}
	
	//-----------------------list
	@Override
	public List<?> companyList() {
		return companybasicDao.findModel("ALL", 10);
	}

	@Override
	public List<?> personalList() {
		return personalbasicDao.findModel("ALL", 10);
	}	

	@Override
	public List<?> contactList(int id) {
		return companycontactDao.findModel("cid="+id, 10);
	}
	
	@Override
	public List<?> bankcreditList(int id) {
		return companybankcreditDao.findModel("cid="+id, 10);
	}
	
	@Override
	public List<?> manageList(int id) {
		// TODO Auto-generated method stub
		return companymanageDao.findModel("cid="+id, 10);
	}


	
	@Override
	public List<?> topmanagerList(int id) {
		return companytopmanagerDao.findModel("cid="+id, 10);
	}

	@Override
	public List<?> prosecutedList(int id) {
		return companyprosecutedDao.findModel("cid="+id, 10);
	}

	@Override
	public List<?> listingList(int id) {
		return companylistingDao.findModel("cid="+id, 10);
	}

	@Override
	public List<?> investorList(int id) {
		return companyinvestorDao.findModel("cid="+id, 10);
	}

	@Override
	public List<?> guarantorList(int id) {
		return companyguarantorDao.findModel("cid="+id, 10);
	}

	@Override
	public List<?> foreigninvestorList(int id) {
		return companyforeigninvestmentDao.findModel("cid="+id, 10);
	}

	@Override
	public List<?> pledgerList(int id,int type) {
		return companypledgerDao.findModel("cid="+id+" and typecustom="+type, 10);
	}

	@Override
	public List<?> givingcreditList(int id) {
		return companygivingcreditDao.findModel("cid="+id, 10);
	}

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`

	@Override
	public Companybasic companyShow(int id) {
		return companybasicDao.findOne("id",id);
	}
	
	@Override
	public Companypledger pledgerShow(int id) {
		return companypledgerDao.findOne("id",id);
	}

	@Override
	public Companycontact contactShow(int id) {
		return companycontactDao.findOne("id",id);
	}

	@Override
	public Companymanage manageShow(int id) {
		// TODO Auto-generated method stub
		return companymanageDao.findOne("id", id);
	}

	
	@Override
	public Companyforeigninvestment foreigninvestorShow(int id) {
		return companyforeigninvestmentDao.findOne("id",id);
	}

	@Override
	public Companygivingcredit givingcreditShow(int id) {
		return companygivingcreditDao.findOne("id",id);
	}

	@Override
	public Companyguarantor guarantorShow(int id) {
		return companyguarantorDao.findOne("id",id);
	}

	@Override
	public Companyinvestor investorShow(int id) {
		return companyinvestorDao.findOne("id",id);
	}

	@Override
	public Companylisting listingShow(int id) {
		return companylistingDao.findOne("id",id);
	}

	@Override
	public Companyprosecuted prosecutedShow(int id) {
		return companyprosecutedDao.findOne("id",id);
	}

	@Override
	public Companytopmanager topmanagerShow(int id) {
		return companytopmanagerDao.findOne("id",id);
	}
	
	////////////////////////////////////////////////////////////////////
	public CompanypledgerDao getCompanypledgerDao() {
		return companypledgerDao;
	}

	public void setCompanypledgerDao(CompanypledgerDao companypledgerDao) {
		this.companypledgerDao = companypledgerDao;
	}

	public CompanyforeigninvestmentDao getCompanyforeigninvestmentDao() {
		return companyforeigninvestmentDao;
	}

	public void setCompanyforeigninvestmentDao(
			CompanyforeigninvestmentDao companyforeigninvestmentDao) {
		this.companyforeigninvestmentDao = companyforeigninvestmentDao;
	}

	public CompanygivingcreditDao getCompanygivingcreditDao() {
		return companygivingcreditDao;
	}

	public void setCompanygivingcreditDao(CompanygivingcreditDao companygivingcreditDao) {
		this.companygivingcreditDao = companygivingcreditDao;
	}

	public CompanyguarantorDao getCompanyguarantorDao() {
		return companyguarantorDao;
	}

	public void setCompanyguarantorDao(CompanyguarantorDao companyguarantorDao) {
		this.companyguarantorDao = companyguarantorDao;
	}

	public CompanyinvestorDao getCompanyinvestorDao() {
		return companyinvestorDao;
	}

	public void setCompanyinvestorDao(CompanyinvestorDao companyinvestorDao) {
		this.companyinvestorDao = companyinvestorDao;
	}

	public CompanytopmanagerDao getCompanytopmanagerDao() {
		return companytopmanagerDao;
	}

	public void setCompanytopmanagerDao(CompanytopmanagerDao companytopmanagerDao) {
		this.companytopmanagerDao = companytopmanagerDao;
	}

	public CompanyprosecutedDao getCompanyprosecutedDao() {
		return companyprosecutedDao;
	}

	public void setCompanyprosecutedDao(CompanyprosecutedDao companyprosecutedDao) {
		this.companyprosecutedDao = companyprosecutedDao;
	}

	public CompanylistingDao getCompanylistingDao() {
		return companylistingDao;
	}

	public void setCompanylistingDao(CompanylistingDao companylistingDao) {
		this.companylistingDao = companylistingDao;
	}

	public PersonalbasicDao getPersonalbasicDao() {
		return personalbasicDao;
	}

	public void setPersonalbasicDao(PersonalbasicDao personalbasicDao) {
		this.personalbasicDao = personalbasicDao;
	}

	public CompanybasicDao getCompanybasicDao() {
		return companybasicDao;
	}

	public void setCompanybasicDao(CompanybasicDao companybasicDao) {
		this.companybasicDao = companybasicDao;
	}

	public CompanycontactDao getCompanycontactDao() {
		return companycontactDao;
	}

	public void setCompanycontactDao(CompanycontactDao companycontactDao) {
		this.companycontactDao = companycontactDao;
	}


	@Override
	public Companyexternalguarantee externalguaranteeShow(int id) {
		// TODO Auto-generated method stub
		return companyexternalguaranteeDao.findOne("id",id);
	}


	public CompanyexternalguaranteeDao getCompanyexternalguaranteeDao() {
		return companyexternalguaranteeDao;
	}


	public void setCompanyexternalguaranteeDao(
			CompanyexternalguaranteeDao companyexternalguaranteeDao) {
		this.companyexternalguaranteeDao = companyexternalguaranteeDao;
	}


	@Override
	public void externalguaranteeSave(
			Companyexternalguarantee cexternalguarantee) {
		
		companyexternalguaranteeDao.save(cexternalguarantee);	
	}


	@Override
	public List<?> externalguaranteeList(int id) {
		// TODO Auto-generated method stub
		return companyexternalguaranteeDao.findModel("cid="+id, 10);
	}


	@Override
	public void companyDelete(Companybasic cbasic) {
		// TODO Auto-generated method stub
		companybasicDao.delete(cbasic);
	}


	@Override
	public void contactDelete(Companycontact ccontact) {
		// TODO Auto-generated method stub
		companycontactDao.delete(ccontact);
	}


	@Override
	public void topmanagerDelete(Companytopmanager ctopmanager) {
		// TODO Auto-generated method stub
		companytopmanagerDao.delete(ctopmanager);
	}


	@Override
	public void prosecutedDelete(Companyprosecuted cprosecuted) {
		// TODO Auto-generated method stub
		companyprosecutedDao.delete(cprosecuted);
	}


	@Override
	public void investorDelete(Companyinvestor cinvestor) {
		// TODO Auto-generated method stub
		companyinvestorDao.delete(cinvestor);
	}


	@Override
	public void foreigninvestorDelete(Companyforeigninvestment cforeigninvestor) {
		// TODO Auto-generated method stub
		companyforeigninvestmentDao.delete(cforeigninvestor);
	}


	@Override
	public void pledgerDelete(Companypledger companypledger) {
		// TODO Auto-generated method stub
		companypledgerDao.delete(companypledger);
	}


	@Override
	public void externalguaranteeDelete(
			Companyexternalguarantee cexternalguarantee) {
		// TODO Auto-generated method stub
		companyexternalguaranteeDao.delete(cexternalguarantee);
	}


	@Override
	public void bankcreditSave(Companybankcredit cbankcredit) {
		// TODO Auto-generated method stub
		companybankcreditDao.save(cbankcredit);
	}


	@Override
	public Companybankcredit bankcreditShow(int id) {
		// TODO Auto-generated method stub
		return companybankcreditDao.findOne("id", id);
	}


	@Override
	public void bankcreditDelete(Companybankcredit cbankcredit) {
		// TODO Auto-generated method stub
		companybankcreditDao.delete(cbankcredit);
	}


	@Override
	public void manageDelete(Companymanage cmanage) {
		// TODO Auto-generated method stub
		companymanageDao.delete(cmanage);
	}


	@Override
	public void assetsdebtSave(
			Companyassetsdebt cassetsdebt) {
		// TODO Auto-generated method stub
		assetsdebtDao.save(cassetsdebt);
	}


	@Override
	public List<?> assetsdebtList(int id) {
		// TODO Auto-generated method stub
		return assetsdebtDao.findModel("cid="+id, 10);
	}


	@Override
	public Companyassetsdebt assetsdebtShow(int id) {
		// TODO Auto-generated method stub
		return assetsdebtDao.findOne("id",id);
	}


	@Override
	public void assetsdebtDelete(
			Companyassetsdebt cassetsdebt) {
		// TODO Auto-generated method stub
		assetsdebtDao.delete(cassetsdebt);
	}


	@Override
	public void cashflowSave(Companycashflow ccf) {
		// TODO Auto-generated method stub
		companycashflowDao.save(ccf);
	}


	@Override
	public List<?> cashflowList(int id) {
		// TODO Auto-generated method stub
		return companycashflowDao.findModel("cid="+id, 10);
	}


	@Override
	public Companycashflow cashflowShow(int id) {
		// TODO Auto-generated method stub
		return companycashflowDao.findOne("id", id);
	}


	@Override
	public void cashflowDelete(Companycashflow ccashflow) {
		// TODO Auto-generated method stub
		companycashflowDao.delete(ccashflow);
	}


	@Override
	public void profitSave(Companyprofit cprofit) {
		// TODO Auto-generated method stub
		companyprofitDao.save(cprofit);
	}


	@Override
	public List<?> profitList(int id) {
		// TODO Auto-generated method stub
		return companyprofitDao.findModel("cid="+id,10);
	}


	@Override
	public Companyprofit profitShow(int id) {
		// TODO Auto-generated method stub
		return companyprofitDao.findOne("id",id);
	}


	@Override
	public void profitDelete(Companyprofit cprofit) {
		// TODO Auto-generated method stub
		companyprofitDao.delete(cprofit);
	}


	@Override
	public List<?> otherloanList(int id) {
		// TODO Auto-generated method stub
		return companyotherloanDao.findModel("cid="+id, 10);
	}


	@Override
	public void otherloanSave(Companyotherloan cotherloan) {
		// TODO Auto-generated method stub
		companyotherloanDao.save(cotherloan);
	}


	@Override
	public Companyotherloan otherloanShow(int id) {
		// TODO Auto-generated method stub
		return companyotherloanDao.findOne("id", id);
	}


	@Override
	public void otherloanDelete(Companyotherloan cotherloan) {
		// TODO Auto-generated method stub
		companyotherloanDao.delete(cotherloan);
	}


	@Override
	public void fileSave(Companyfile cfile) {
		// TODO Auto-generated method stub
		companyfileDao.save(cfile);
	}


	@Override
	public Companyfile fileShow(int id) {
		// TODO Auto-generated method stub
		return companyfileDao.findOne("id", id);
	}


	@Override
	public List<?> fileList(int id) {
		// TODO Auto-generated method stub
		
		return companyfileDao.findModel("cid="+id, 10);
	}


	@Override
	public void fileDelete(Companyfile cfile) {
		// TODO Auto-generated method stub
		companyfileDao.delete(cfile);
	}


	@Override
	public Companyfile fileFindByType(int cid, int type) {
		// TODO Auto-generated method stub
		return companyfileDao.findByOne("cid="+cid + " and type="+type);
	}

}
